/*
*** (C) 2008 UCMai.com ***

Subj: 自定义Window对象
Auth: lingq
Date: 2008-05-30
*/
Ext.namespace("Ext.ux"); 
Ext.ux.Window = Ext.extend(Ext.Window,{
	buttonAlign : 'right',
	closable:true,
	resizable: false,
	layout:'fit',
	modal: 'true',
	closeAction:'hide',
	plain: true,

	firstItem:'',
	handler:'',

	bTitle:false,

	grid:null,
	form:null,

	//private
	initComponent : function() {
		this.initWin();
		Ext.ux.Window.superclass.initComponent.call(this);
	},

	initWin : function(){
		this.add(this.form);
		this.keys = {
			key: Ext.EventObject.ENTER,
			fn: this.handler.createDelegate(this.grid,[this.bTitle])
		};
		
		var btnSave = new Ext.Button({
			id: 'btnSave',
			text: c.bsave,
			handler: this.handler.createDelegate(this.grid,[this.bTitle])
		});
		var btnCancel = new Ext.Button({
			id:'btnCancel',
			text: c.bcancel,
			handler: function(){this.hide();}.createDelegate(this)
		});
		this.addButton(btnSave);
		this.addButton(btnCancel);

		this.on('hide',function(){this.form.destroy();}.createDelegate(this));
		this.show();
		this.form.findById(this.firstItem).focus(false,true);
		this.setTitle((this.bTitle)?c.ad():c.md());
		if(!this.bTitle){
			/* local mode */
			this.form.getForm().setValues(this.grid.getSelectionModel().getSelected().data);
		}
	}
});